package com.fss.application1.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fss.common.annotation.Log;
import com.fss.common.core.controller.BaseController;
import com.fss.common.core.domain.AjaxResult;
import com.fss.common.enums.BusinessType;
import com.fss.application1.domain.LoanApplication1;
import com.fss.application1.service.ILoanApplication1Service;
import com.fss.common.utils.poi.ExcelUtil;
import com.fss.common.core.page.TableDataInfo;

/**
 * 贷款申请Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/application1/application1")
public class LoanApplication1Controller extends BaseController
{
    @Autowired
    private ILoanApplication1Service loanApplication1Service;

    /**
     * 查询贷款申请列表
     */
    @PreAuthorize("@ss.hasPermi('application1:application1:list')")
    @GetMapping("/list")
    public TableDataInfo list(LoanApplication1 loanApplication1)
    {
        startPage();
        List<LoanApplication1> list = loanApplication1Service.selectLoanApplication1List(loanApplication1);
        return getDataTable(list);
    }

    /**
     * 导出贷款申请列表
     */
    @PreAuthorize("@ss.hasPermi('application1:application1:export')")
    @Log(title = "贷款申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LoanApplication1 loanApplication1)
    {
        List<LoanApplication1> list = loanApplication1Service.selectLoanApplication1List(loanApplication1);
        ExcelUtil<LoanApplication1> util = new ExcelUtil<LoanApplication1>(LoanApplication1.class);
        util.exportExcel(response, list, "贷款申请数据");
    }

    /**
     * 获取贷款申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('application1:application1:query')")
    @GetMapping(value = "/{applicationId}")
    public AjaxResult getInfo(@PathVariable("applicationId") Long applicationId)
    {
        return success(loanApplication1Service.selectLoanApplication1ByApplicationId(applicationId));
    }

    /**
     * 新增贷款申请
     */
    @PreAuthorize("@ss.hasPermi('application1:application1:add')")
    @Log(title = "贷款申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LoanApplication1 loanApplication1)
    {
        return toAjax(loanApplication1Service.insertLoanApplication1(loanApplication1));
    }

    /**
     * 修改贷款申请
     */
    @PreAuthorize("@ss.hasPermi('application1:application1:edit')")
    @Log(title = "贷款申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LoanApplication1 loanApplication1)
    {
        return toAjax(loanApplication1Service.updateLoanApplication1(loanApplication1));
    }

    /**
     * 删除贷款申请
     */
    @PreAuthorize("@ss.hasPermi('application1:application1:remove')")
    @Log(title = "贷款申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applicationIds}")
    public AjaxResult remove(@PathVariable Long[] applicationIds)
    {
        return toAjax(loanApplication1Service.deleteLoanApplication1ByApplicationIds(applicationIds));
    }
}
